#!/bin/bash

env_script="envsetup.sh"
config_file=".mm_param"
cmake_args=""
release_list=""
build_dir=""
build_type=""
cmd_arg_mode=""
cmd_arg_dir=""

colors=$(tput colors 2>/dev/null)
if [ $? = 0 ] && [ $colors -gt 8 ]; then
    FG_BLUE='\033[38;5;33m'
    FG_GREEN='\033[38;5;10m'
    FG_DEF='\033[39m'
else
    FG_BLUE=''
    FG_GREEN=''
    FG_DEF=''
fi

PrintUsage()
{
    printf "Usage: %s <OPTION> <VALUE>
    Options:
        -d | --dir <dir_name>
        -a | --all
        -r | --release
        -h | --help
    
    Examples:
        %s -d common
" "$0" "$0"

}

Main()
{
    echo "mm.sh running main"
}

if [ $# == 0 ]; then
    PrintUsage
    exit 1
fi

if ! ARGS=$(getopt -a -o d:arh -l dir,all,release,help -- "$@"); then
    echo "Param Error"
    PrintUsage
    exit 1
fi

eval set -- "${ARGS}"
while true; do
    echo $1
    case "$1" in
    -d|--dir)
        if [ $1 == 0]; then
            echo "Param Null"
            break;
        fi

        shift   # 输入的参数左移一位
        cmd_arg_dir="$1"
        cmd_arg_mode="compile_dir"
        shift
        ;;
    -a|--all)
        cmd_arg_mode="compile_all"
        shift
        ;;
    -r|--release)
        cmd_arg_mode="release"
        shift
        ;;
    -h|--help)
        PrintUsage
        exit 0
        ;;
    --)
        shift
        break;
        ;;
    *)
        echo "Param Null"
        break;
        ;;

    esac
done

Main
